<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
<style>
*{margin: 0px;padding: 0px}
.box{width:200px;height:200px;background-color:#00eeff;position: absolute}








</style>
</head>
<body>
    <input type="button" value="开始" id="btn">
    <div class="box"></div>
</body>
<script>
    function $(ele){
        return document.querySelector(ele);
    }
    let timer = null;
    let speed = 1;
    $('#btn').onclick = function(){
        // setItnerval(function(){} , ()=>{})
        console.log($('.box').offsetLeft);
        timer = setInterval(() => {
            speed = speed+$('.box').offsetLeft/100;

            if($('.box').offsetLeft>=1000){
                clearInterval(timer)
            }else{
                $('.box').style.left = $('.box').offsetLeft+ speed +'px';
            }
        }, 40);
    }
</script>
</html>